package com.goblin.model.base;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

/**
 * @desc: 代理类处理器.
 * @author goblin
 * @date 2020/10/28 11:41
 */
public class BaseControllerInvocationHandler implements InvocationHandler {

	private Object target;

	public BaseControllerInvocationHandler(Object target) {
		this.target = target;
	}

	@Override
	public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {

		Object result = method.invoke(this.target, args);

		return result;
	}

	// 生成代理类
	public Object CreatProxyedObj() {
		return Proxy.newProxyInstance(target.getClass().getClassLoader(),
				target.getClass().getInterfaces(), this);
	}
}
